﻿@{
    ViewBag.Title = "个人工作台";
}
@model String
@using Wicresoft.UnifyShow.Business
@{
    var Announcement = ViewData["Announcement"] as List<AnnouncementModel>;
    var totalCount = (decimal)ViewData["AnnouncementCount"];
    var hasDuty = (bool)ViewData["HasTodayDuty"];

    var CommonResources = ViewData["CommonResources"] as List<CommonResourceModel>;
    var ResourceCount = (decimal)ViewData["ResourceCount"];

    var OpsResources = ViewData["OpsResources"] as List<CommonResourceModel>;
    var OpsCount = (decimal)ViewData["OpsCount"];
    
    
}
@section ScriptAndCss{
    <style type="text/css">
        #AnnouncementContainer li {
            padding-left: 14px;
            cursor: pointer;
            margin: 0 0 0 14px;
            padding: 3px 0;
            height: 8%;
        }

        #ResourceContainer li {
            padding-left: 14px;
            cursor: pointer;
            margin: 0 0 0 14px;
            padding: 3px 0;
            height: 8%;
        }

        #OpsContainer li {
            padding-left: 14px;
            cursor: pointer;
            margin: 0 0 0 14px;
            padding: 3px 0;
            height: 8%;
        }

        .announcementInner {
            display: inline-block;
            *display: inline;
            *zoom: 1;
            width: 80%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
    </style>
    <script type="text/javascript">
        function formateDesc(value, row, index) {
            var abValue = value;
            if (value.length >= 22) {
                abValue = value.substring(0, 19) + "...";
            }
            var content = '<a href="#" title="' + value + '" class="note">' + abValue + '</a>';
            return content;
        }
        $(function () {
            $("#DutyToday").load("@Url.Action("List", "DutyPlan")");

            $('#dg').datagrid({
                onLoadSuccess: function (data) {
                    $(".note").tooltip({
                        onShow: function () {
                            $(this).tooltip('tip').css({
                                maxWidth: 300,
                                boxShadow: '1px 1px 3px #292929'
                            });
                        }
                    });
                },
                onDblClickRow: function (rowIndex, rowData) {
                    var rnd = (new Date()).getMilliseconds() + "" + parseInt(Math.random() * 10000);
                    if (rowData.TypeS == "任务") {
                        window.open("/PlanManagement/TaskDetail?UserRole=2&ID=" + rowData.RequestID);
                        return false;
                    }
                    $.ajax({
                        url: '/Navigate/GetURL',
                        data: { type: rowData.TypeS, requestid: rowData.RequestID, operation: rowData.Operation, nocatch: rnd },
                        success: function (result) {
                            window.open("/Account/SSO?redirectionUrl=" + encodeURI(result) + "catchid=" + rnd);
                        }

                    });
                }
            });
            $('#dg').datagrid("hideColumn", 'RequestID');
            var p = $('#dg').datagrid('getPager');

            $(p).pagination({
                beforePageText: '第',

                afterPageText: '页    共 {pages} 页',

                displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'

            });
            $('#dg2').datagrid({
                onLoadSuccess: function (data) {
                    $(".note").tooltip({
                        onShow: function () {
                            $(this).tooltip('tip').css({
                                maxWidth: 300,
                                boxShadow: '1px 1px 3px #292929'
                            });
                        }
                    });
                },
                onDblClickRow: function (rowIndex, rowData) {
                    var rnd = (new Date()).getMilliseconds() + "" + parseInt(Math.random() * 10000);
                    $.ajax({
                        url: '/Navigate/GetURL',
                        data: { type: rowData.TypeS, requestid: rowData.RequestID, nocatch: rnd },
                        success: function (result) {
                            window.open("/Account/SSO?redirectionUrl=" + encodeURI(result) + "catchid=" + rnd);
                        }

                    });
                }
            });
            $('#dg2').datagrid("hideColumn", 'RequestID');
            var p2 = $('#dg2').datagrid('getPager');

            $(p2).pagination({
                beforePageText: '第',

                afterPageText: '页    共 {pages} 页',

                displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'

            });
        });
    </script>
}
<div class="main_table">
    <div class="padding5" style="height: 49%;">
        <div class="easyui-panel" fit="true" title="待办事宜" data-options="tools:'#todoMore'">
            <table id="dg" fit="true" class="easyui-datagrid" pagination="true" url="/Navigate/toDoWorkList"
                fitcolumns="true" singleselect="true">
                <thead>
                    <tr>
                        <th field="RequestID" width="180">请求ID
                        </th>
                        <th field="IDS" width="180" sortable="true">请求ID
                        </th>
                        <th field="TypeS" width="90" sortable="true">请求类型
                        </th>
                        <th field="Operation" width="60" sortable="true">操作
                        </th>
                        <th field="Description" width="150" resizable="false" formatter="formateDesc" sortable="true">摘要
                        </th>
                        <th field="Status" width="80" sortable="true">状态
                        </th>
                        <th field="Priority" width="80" sortable="true">优先级
                        </th>
                        <th field="AssignGroup" width="100" sortable="true">受派者组
                        </th>
                        <th field="Assigner" width="100" sortable="true">受派者
                        </th>
                        <th field="Submitter" width="120" sortable="true">建单人
                        </th>
                        <th field="CreateDate" width="180" sortable="true">建单日期
                        </th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
    <div class="padding5" style="height: 49%;">
        <table id="dg2" fit="true" class="easyui-datagrid" title="在办事宜" pagination="true"
            url="/Navigate/DoingWorkList" fitcolumns="true" singleselect="true">
            <thead>
                <tr>
                    <th field="RequestID" width="180">请求ID
                    </th>
                    <th field="IDS" width="180" sortable="true">请求ID
                    </th>
                    <th field="TypeS" width="90" sortable="true">请求类型
                    </th>
                    <th field="Operation" width="60" sortable="true">操作
                    </th>
                    <th field="Description" width="150" resizable="false" formatter="formateDesc" sortable="true">摘要
                    </th>
                    <th field="Status" width="80" sortable="true">状态
                    </th>
                    <th field="Priority" width="80" sortable="true">优先级
                    </th>
                    <th field="AssignGroup" width="100" sortable="true">受派者组
                    </th>
                    <th field="Assigner" width="100" sortable="true">受派者
                    </th>
                    <th field="Submitter" width="120" sortable="true">建单人
                    </th>
                    <th field="CreateDate" width="180" sortable="true">建单日期
                    </th>
                </tr>
            </thead>
        </table>
    </div>
    <div id="todoMore">
        <a href="@(Url.Action("Index", "Search"))" style="width:50px">工单搜索</a> <a href="@(Url.Action("Index", "Search"))" class="icon-search"></a>
    </div>
</div>
<div class="main_cont">
    <div class="main_cont_wrapper">
        <div class="main_cont_panel ui-icons">
            <span class="ui-icons icon-list"></span>
            <h3>电子公告</h3>
        </div>
        @*<input type="hidden" value="@(totalCount)" id="AnnouncementCount" />*@
        <div class="main_cont_menu" id="AnnouncementContainer">
            <ul class="origin" style="list-style: disc inside; height: 100%;">
                @{
                    foreach (var item in Announcement)
                    { 
                    <li onclick="openAnnouncementDetail(@item.ID);" style="list-style: disc inside;"><span
                        class="announcementInner">
                        @(item.Title)
                    </span></li>
                    }

                    if (Announcement.Count > 4)
                    {
                    <li style="text-align: right; height: 15px; font-weight: bold; position: absolute; right: 10px; bottom: 0px;"><a href="/PlanManagement/AnnouncementList">>>更多...</a>
                    </li>
                    }
                }
            </ul>
        </div>
    </div>
    <div class="main_cont_wrapper">
        <div class="main_cont_panel ui-icons">
            <span class="ui-icons icon-list"></span>
            <h3 style="display: inline-block; *display: inline; *zoom: 1;"><a style="color: White" onclick="openDutyList()">值班计划</a></h3>
            @if (hasDuty)
            {
                <a style="float: right; line-height: 23px; color: white; padding-right: 10px;" onclick="openDutyDetail()">值班记录<span class="icon-edit" style="background-position: 0 0;"></span></a>
            }
        </div>
        <div class="main_cont_menu" id="DutyToday">
        </div>
    </div>
    <div class="main_cont_wrapper">
        <div class="main_cont_panel ui-icons">
            <span class="ui-icons icon-list"></span>
            <h3>运维报告</h3>
        </div>
        <input type="hidden" value="@(OpsCount)" id="OpsCount" />
        <div class="main_cont_menu" id="OpsContainer">
            <ul class="origin" style="list-style: disc inside; height: 100%;">
                @{
                    foreach (var item in OpsResources)
                    { 
                    <li style="list-style: disc inside;"><span class="announcementInner"><a href="@item.Url">@(item.DName)</a>
                    </span></li>
                    }

                    if (OpsResources.Count > 4)
                    {
                    <li style="text-align: right; height: 15px; font-weight: bold; position: absolute; right: 10px; bottom: 0px;"><a href="/OpsReport/Search">>>更多...</a> </li>
                    }
                }
            </ul>
        </div>
    </div>
    <div class="main_cont_wrapper">
        <div class="main_cont_panel ui-icons">
            <span class="ui-icons icon-list"></span>
            <h3>常用资源</h3>
        </div>
        <input type="hidden" value="@(ResourceCount)" id="ResourceCount" />
        <div class="main_cont_menu" id="ResourceContainer">
            <ul class="origin" style="list-style: disc inside; height: 100%;">
                @{
                    foreach (var item in CommonResources)
                    { 
                    <li style="list-style: disc inside;"><span class="announcementInner"><a href="@item.Url">@(item.DName)</a>
                    </span></li>
                    }

                    if (CommonResources.Count > 4)
                    {
                    <li style="text-align: right; height: 15px; font-weight: bold; position: absolute; right: 10px; bottom: 0px;"><a href="/ComResource/Search">>>更多...</a> </li>
                    }
                }
            </ul>
        </div>
    </div>
    @*    <div class="main_cont_wrapper">
        <div class="main_cont_panel ui-icons">
            <span class="ui-icons icon-list" style="cursor: pointer;" onclick="openComResourceList()"></span>
            <h3 style="display: inline-block; *display: inline; *zoom: 1;">常用资源</h3>
        </div>
        <div class="main_cont_menu" id="ResourceList">
        </div>
    </div>*@
</div>
<script type="text/javascript">

    var openDialog = function (url, width, height) {
        var _w = 1160, _h = 630;
        _w = width || _w;
        _h = height || _h;

        var iTop = 20; //获得窗口的垂直位置;
        var iLeft = (window.screen.availWidth - 10 - _w) / 2; //获得窗口的水平位置;
        window.open(url, "_blank", "width=" + _w + ",height=" + _h + ",top=" + iTop + ",left=" + iLeft + ",resizable=1,scrollbars=1,fullscreen=0");
    };

    var showModuleDialog = function (url, width, height) {
        var _w = 900, _h = 650;
        _w = width || _w;
        _h = height || _h;
        openDialog(url, _w, _h);
    }

    var openAnnouncementDetail = function (id) {
        openDialog('/PlanManagement/AnnouncementDetail?ID=' + id + '&canEdit=false', 800, 550);
    };

    var CommonResourceDownload = function (id) {
        window.open("@Url.Action("DownLoad", "ComResource")" + "?id=" + id);
    };

    var OpsResourceDownload = function (id) {
        window.open("@Url.Action("DownLoad", "OpsReport")" + "?id=" + id);
    };

    //打开排班计划列表页
    var openDutyLogList = function () {
        showModuleDialog('/DutyPlan/SeeDutyPlan');
    };

    //打开常用资搜索界面
    var openComResourceList = function () {
        showModuleDialog('/ComResource/Search')
    }

    //打开值班记录详情页面
    var openDutyDetail = function () {
        showModuleDialog('/DutyPlan/Edit?Status=ADD');
    };


    var openDutyList = function () {
        showModuleDialog('/DutyPlan/SeeDutyPlan');
    };
</script>
